﻿Shader "Custom/SideBySideStereoImageByCol"
{
    Properties
    {
        _LCamTex ("LeftCameraTexture", 2D) = "white" { }
        _RCamTex ("RightCameraTexture", 2D) = "white" { }
        _ScreenWidth ("ScreenWidth", float) = 1920
        _ScreenHeight ("ScreenHeight", float) = 1080
    }
    SubShader
    {
        // No culling or depth
        Cull Off ZWrite Off ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            sampler2D _LCamTex;
            sampler2D _RCamTex;
            float _ScreenWidth;
            float _ScreenHeight;

            fixed4 frag(v2f i) : SV_Target
            {
                fixed4 col;
                //float width = 1920;
                //float height = 1152.0;



                //隔列
                if (floor(fmod(float(i.uv.x * _ScreenWidth), 2.0)) == 0.0)
                {
                   
                    col = tex2D(_LCamTex, float2(i.uv.x / 2, i.uv.y));
                }
                else
                {
                    col = tex2D(_RCamTex, float2(i.uv.x / 2, i.uv.y));
                }
 
          clip(col.a - 0.5);
    
if(col.a<0.5)
col.a=0;
                return col;
            }
            ENDCG
        }
    }
}
